#{extends 'ApiDoc/base.html'/}

<script>
    $(function(){
        activeMenu('${serviceJson.getString('name')}.${apiJson.getString('name')}');
    });
</script>

<link rel="stylesheet" type="text/css"
      href="#{href '/public/apidoc/layout/res_iframe.css'/}"/>

<link rel="stylesheet" href="#{href '/public/apidoc/view.css'/}">

<div class="page_doc">
    <div class="main_hd"><h2 id="title">${serviceJson.getString('title')} - ${apiJson.getString('title')}</h2></div>
    <div class="main_bd">
        <div class="article_box">
            <div class="inner">
                <div id="content" class="news_content">
                    <!-- 1. 接口文字说明 -->
                    <h2>1. 概要说明</h2>
                    <p class="p">
                        ${apiJson.getString('desc').nl2br()}
                    </p>

                    <!-- 2. 接口调用说明 -->
                    <h2>2. 调用说明</h2>
                    <div>
                        <div class="code-text">${apiJson.getString('url')}</div>
                    </div>


                    <!-- 3. 接口参数说明 -->
                    <h2>3. 参数说明</h2>
                    <table class="table">
                        <thead>
                        <tr>
                            <th>参数</th>
                            <th>类型</th>
                            <th>备注</th>
                            <th>必填</th>
                        </tr>
                        </thead>
                        <tbody>
                        #{list items: apiJson.getJSONArray('params'), as: 'param'}
                        <tr>
                            <td class="code-text">${param.getString('name')}</td>
                            <td class="code-text">${param.getString('type')}</td>
                            <td>
                                ${param.getString('title')}
                                #{if param.getString('note')}
                                ，${param.getString('note')}
                                #{/if}
                            </td>
                            <td>${param.getBoolean('isRequired') ? '必填': '选填'}</td>
                        </tr>
                        #{/list}
                        </tbody>
                    </table>

                    <!-- 4. 接口返回说明 -->
                    <h2>4. 返回说明</h2>

                    <table class="table">
                        <thead>
                        <tr>
                            <th>字段</th>
                            <th>类型</th>
                        </tr>
                        </thead>
                        <tbody>
                        #{list items: apiJson.getJSONArray('result'), as: 'result'}
                        %{
                            def type = result.getString('type')
                            def isPr = false;
                            if(type == 'Integer'
                                    || type == 'Double'
                                    || type == 'Float'
                                    || type == 'Boolean'
                                    || type == 'Long'
                                    || type == 'Byte'
                                    || type == 'Short'
                                    || type == 'String'
                                    || type == 'Object'){
                                isPr = true;
                            }
                        }%
                        #{if result.getBoolean('isList')}
                        <tr>
                            <td class="code-text">${result.getString('name')}</td>
                            <td>
                                List&lt;
                                #{if isPr}
                                    ${result.getString('type')}
                                #{/if}
                                #{else}
                                    <a href="/@apidoc/api_json/bean/${result.getString('type')}">${result.getString('type')}</a>
                                #{/else}
                                &gt;
                            </td>
                        </tr>
                        #{/if}
                        #{else}
                        <tr>
                            <td class="code-text">${result.getString('name')}</td>
                            <td>
                                #{if isPr}
                                    ${result.getString('type')}
                                #{/if}
                                #{else}
                                    <a href="/@apidoc/api_json/bean/${result.getString('type')}">${result.getString('type')}</a>
                                #{/else}
                            </td>
                        </tr>
                        #{/else}
                        #{/list}
                        </tbody>
                    </table>

                    <!-- 5. 源代码 -->
                    <h2>5. 源代码</h2>
                    <div>
                        <pre><code class="language-java">${apiJson.getString('code').raw()}</code></pre>
                    </div>
                </div>
            </div>
        </div>
    </div>

</div>